//
//  ZJUserAccount.m
//  Weibo29
//
//  Created by 曾静 on 16/6/30.
//  Copyright © 2016年 qq. All rights reserved.
//

#import "ZJUserAccount.h"

@interface ZJUserAccount()<NSCoding>

@end
@implementation ZJUserAccount

/**
 *  对象方法，用于实例化对象
 *
 *  @param dict 字典数据
 *
 *  @return 返回当前类的对象
 */
-(instancetype)initWithDict:(NSDictionary *)dict{
    if (self = [super init]) {
        [self  setValuesForKeysWithDictionary:dict];
    }
    return self;
}

//归档,归档接档的具体实现
- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super init];
    if (self) {
        [coder decodeObjectForKey:@"uid"];
         [coder decodeObjectForKey:@"expires_in"];
         [coder decodeObjectForKey:@"access_token"];
        [coder decodeObjectForKey:@"remind_in"];
        
    }
    return self;
}
//接档
- (void)encodeWithCoder:(NSCoder *)coder
{
    
    [coder encodeObject:self.uid forKey:@"uid"];
    [coder encodeObject:self.expires_in forKey:@"expires_in"];
    [coder encodeObject:self.access_token forKey:@"access_token"];
    [coder encodeObject:self.remind_in forKey:@"remind_in"];
  
}
/**
 *  类方法，用于实例化对象
 *
 *  @param dict 字典数据
 *
 *  @return 返回当前类的对象
 */
+(instancetype)userAccountWithDict:(NSDictionary *)dict{
    return [[self alloc]initWithDict:dict];
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key{
    //空实现,以便有的键值找不到
}

-(NSString *)description{
    return [NSString stringWithFormat:@"%@,%@,%@,%@",self.uid,self.expires_in,self.access_token,self.remind_in];
}
@end
